import { lazy,Suspense } from 'react'
import { useRoutes } from 'react-router'
const Login = lazy(() => import('../pages/Login'))
const Reg = lazy(() => import('../pages/Reg'))
const Home = lazy(() => import('../pages/Home'))
const Test = lazy(() => import('../pages/Test'))
const Student = lazy(() => import('../pages/Student'))
const routers=[
    {
        path:"/home",
        element:<Suspense fallback={<div>加载中</div>}>
            <Home />
        </Suspense>,
        children:[
            {
                path:"test/:id",
                element:<Test></Test>
            },
            {
                path:"stu",
                element:<Student></Student>
            }
        ]
    },
    {
        path:"/login",
        element:<Suspense fallback={<div>加载中</div>}>
            <Login />
        </Suspense>
    },
    {
        path:"/reg",
        element:<Suspense fallback={<div>加载中</div>}>
            <Reg />
        </Suspense>
    }
]

export default ()=>{

    return useRoutes(routers)
}